<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@ include file="/common/meta.jsp"%>
</head>
<body>
	<div class="wrap">
		<div class="header_bg">
			<%@ include file="/common/header.jsp"%>
	    </div>
	    <div class="w">
	    	<div class="path box">
	    		<jsp:include page="/common/frame/frame_path.jsp">
            		<jsp:param name="current" value="订单管理"/>
            	</jsp:include>
	        </div>
	    </div>
	    <div class="main">
	    	<div class="list box">
	        	<div class="pc_left">
	            	<jsp:include page="/common/frame/frame_left.jsp">
	            		<jsp:param name="checked" value="order"/>
	            	</jsp:include>
	            </div>
	            <div class="pc_right">
	                <div class="pc_m fl">
	                	<div class="reserve">
	                    	<h2 class="font_s">来自 <a href="#">${order.userName}</a> 的预约申请 <span>（<fmt:formatDate value="${order.createDate}" type="both" pattern="yyyy/MM/dd HH:mm"/>）</span></h2>
	                        <p>预约编号：<span>${order.orderNo}</span><br />预约日期：<span><fmt:formatDate value="${order.orderStartDate}" type="date" pattern="yyyy/MM/dd"/> - <fmt:formatDate value="${order.orderEndDate}" type="date" pattern="yyyy/MM/dd"/></span> （${order.days} 天）<br />宠物数量：<span>1</span></p>
	                        <c:forEach items="${order.petList}" var="pet">
	                        <div class="pet_new">
	                        	<div class="pet_img fl"><img src="${ctx}/tools/download.do?dir=PET&fileName=${pet.petPhotoPath}" width="110" height="110"/></div>
	                            <p class="fl"><span>${pet.petName}</span><br />${pet.petAge}岁 / 男孩<br />小型犬 其他品种</p>
	                        </div>
	                        </c:forEach>
	                        留言：<p>${order.userRemark}</p>
	                    </div>
	                    <c:if test="${user != null && host != null}">
	                    <div class="reserve">
	                    	<h2 class="font_s">${host.hostName}</span></h2>
	                        <p>
		                        详细地址：<span>${host.hostAddress}</span><br />
		                        店主姓名：<span>${hostUser.userName}</span><br />
		                        联系电话：<span>${hostUser.userTel}</span><br />
	                        </p>
	                    </div>
	                    </c:if>
	                    <div class="btn">
	                    	<c:if test="${order.isHost && order.status == 10}">
<%-- 		                    <a href="javascript:void(0)" onclick="tendog.win.createQuotation(${order.id})">接受并发送报价</a> --%>
							<a href="javascript:void(0)" onclick="agreeOrder(${order.id})">接受</a>
		                    <a href="javascript:void(0)" onclick="rejectOrder(${order.id})">拒绝</a>
	                    	</c:if>
	                    	<c:if test="${!order.isHost && order.status == 30}">
	                    	<a href="javascript:void(0)" onclick="tendog.win.appraise(${order.id})">评价</a>
	                    	</c:if>
		                    <a href="${ctx}/frame/order.do">返回列表</a>
	                    </div>
	                </div>
	            </div>
	            <div class="clear"></div>
			</div>
	    </div>
	    <div class="footer_bg">
	    	<%@ include file="/common/footer.jsp"%>
	    </div>
	</div>
<script type="text/javascript">
function rejectOrder(id) {
	msg.confirm("确定要拒绝这次预约?", function(rr) {
		if(rr) {
			$.getJSON("${ctx}/order/reject.do?id=" + id, function(res){
				if(res.code==1) {
					msg.confirm("取消成功，是否返回订单列表?", function(r){
						if(r) {
							tools.href("/frame/order.do");
						} else {
							tools.href("/order/show.do?id=${order.id}");
						}
					});
				} else {
					msg.error(res.msg);
				}
			});
		}
	});
}
function agreeOrder(id) {
	msg.confirm("接受预定后宠物主人将看到您的联系方式以便与您联系，是否接受预约?", function(rr) {
		if(rr) {
			$.getJSON("${ctx}/order/agree.do?id=" + id, function(res){
				if(res.code==1) {
					msg.confirm("接受预约成功，是否返回订单列表?", function(r) {
						if(r) {
							tools.href("/frame/order.do");
						} else {
							tools.href("/order/show.do?id=${order.id}");
						}
					});
				} else {
					msg.error(res.msg);
				}
			});
		}
	});
}
$(function(){
	$(".pet_img img").error(function(){
		$(this).attr("src", "${ctx}/images/pet_no_head.jpg");
	});
});
</script>
</body>
</html>